package com.ruoyi.ies.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ies.domain.TaskAssessment;
import com.ruoyi.ies.service.ITaskAssessmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务考核Controller
 * 
 * @author July
 * @date 2023-06-12
 */
@RestController
@RequestMapping("/ies/assessment")
public class TaskAssessmentController extends BaseController
{
    @Autowired
    private ITaskAssessmentService taskAssessmentService;

    /**
     * 查询任务考核列表
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskAssessment taskAssessment)
    {
        startPage();
        List<TaskAssessment> list = taskAssessmentService.selectTaskAssessmentList(taskAssessment);
        return getDataTable(list);
    }

    /**
     * 导出任务考核列表
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:export')")
    @Log(title = "任务考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskAssessment taskAssessment)
    {
        List<TaskAssessment> list = taskAssessmentService.selectTaskAssessmentList(taskAssessment);
        ExcelUtil<TaskAssessment> util = new ExcelUtil<TaskAssessment>(TaskAssessment.class);
        util.exportExcel(response, list, "任务考核数据");
    }

    /**
     * 获取任务考核详细信息
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:query')")
    @GetMapping(value = "/{workName}")
    public AjaxResult getInfo(@PathVariable("workName") String workName)
    {
        return success(taskAssessmentService.selectTaskAssessmentByWorkName(workName));
    }

    /**
     * 新增任务考核
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:add')")
    @Log(title = "任务考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskAssessment taskAssessment)
    {
        return toAjax(taskAssessmentService.insertTaskAssessment(taskAssessment));
    }

    /**
     * 修改任务考核
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:edit')")
    @Log(title = "任务考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskAssessment taskAssessment)
    {
        return toAjax(taskAssessmentService.updateTaskAssessment(taskAssessment));
    }

    /**
     * 删除任务考核
     */
    @PreAuthorize("@ss.hasPermi('ies:assessment:remove')")
    @Log(title = "任务考核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workNames}")
    public AjaxResult remove(@PathVariable String[] workNames)
    {
        return toAjax(taskAssessmentService.deleteTaskAssessmentByWorkNames(workNames));
    }
}
